package com.kitty.game.role.model;

import com.kitty.common.db.BaseEntityGame;
import com.kitty.common.model.Pos;
import com.kitty.common.utils.SpringUtils;
import com.kitty.game.party.model.Party;
import com.kitty.game.utils.Const;
import lombok.Getter;
import lombok.Setter;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.nutz.dao.entity.annotation.*;

import java.util.Date;

@Table("t_role")
@Setter
@Getter
@TableIndexes({@Index(fields = {"roleId"}, unique = false),
        @Index(fields = {"uid"}, unique = false),
        @Index(fields = {"sid"}, unique = false),
        @Index(fields = {"name"}, unique = false),
        @Index(fields = {"level"}, unique = false)})
@JsonIgnoreProperties(ignoreUnknown =true)
public class RoleSimple extends BaseEntityGame<Long> {
    @Id(auto = false)
    private int roleId;//角色id
    @Column
    private Long uid;//面板ID20位长度
    @Column
    private String sid;//账户ID
    @Column
    private String name;//角色名称
    @Column
    private byte gender;//性别1男2女
    @Column
    @Default(value = "1")
    private short level = 1;
    @Column
    private short polar;//门派 相性
    @Column
    @Comment("坐标数据")
    private Pos pos = new Pos();

    @Column
    @Comment("在线状态")
    private int on_line = 0;
    @Column
    @Comment("累计充值记录")
    @Default("0")
    private int totalCharge;
    @Column
    private Date createTime;


    //排行榜需要的参数
    @Column
    private int phyPower;//物理伤害
    @Column
    private int defense;//防御
    @Column
    private int magPower;//法术伤害
    @Column
    private int speed;//速度
    @Column
    private long taoPoint;//道行
    @Column
    private long monthTaoPoint; //月道行点数
    @Column
    private long prevMonthTaoPoint; // 上月道行点数
    @Column
    private long partyId;//帮派ID
    @Column
    private short roleIcon;//角色图标
    @Column
    private int fight_cap =0;//战力4931008686
    @Column
    private int aitype;
    public boolean isAi(RoleSimple role) {
        if(role.getAitype() == 1 || role.getAitype() == 2 ){
            return true;
        }
        return false;
    }
    /**
     * 取月道行天数
     */
    @JsonIgnore
    public int getMonthTao() {
        return (int) (monthTaoPoint / Const.ONE_DAY_POINT);
    }

    /**
     * 取月道行除去天之后的点数
     */
    @JsonIgnore
    public int getMonthTaoLastPoint() {
        return (int) (monthTaoPoint % Const.ONE_DAY_POINT);
    }
    /**
     * 取道行的天数
     */
    @JsonIgnore
    public int getTao() {
        return (int) (taoPoint / Const.ONE_DAY_POINT);
    }

    /**
     * 取道行除去天之后的点数
     */
    @JsonIgnore
    public int getTaoLastPoint() {
        return (int) (taoPoint % Const.ONE_DAY_POINT);
    }
    @JsonIgnore
    public String getGid() {
        return String.valueOf(uid);
    }
    @JsonIgnore
    /**获得帮派名称*/
    public String getPartyName() {
        Party party = SpringUtils.getPartyService().getParty(partyId);
        if (party != null) {
            return party.getPartyName();
        }

        return null;
    }

    public int getRoleId() {
        return roleId;
    }

    public void setRoleId(int roleId) {
        this.roleId = roleId;
    }

    public Long getUid() {
        return uid;
    }

    public void setUid(Long uid) {
        this.uid = uid;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public byte getGender() {
        return gender;
    }

    public void setGender(byte gender) {
        this.gender = gender;
    }

    public short getLevel() {
        return level;
    }

    public void setLevel(short level) {
        this.level = level;
    }

    public short getPolar() {
        return polar;
    }

    public void setPolar(short polar) {
        this.polar = polar;
    }

    public Pos getPos() {
        return pos;
    }

    public void setPos(Pos pos) {
        this.pos = pos;
    }

    public int getOn_line() {
        return on_line;
    }

    public void setOn_line(int on_line) {
        this.on_line = on_line;
    }

    public int getTotalCharge() {
        return totalCharge;
    }

    public void setTotalCharge(int totalCharge) {
        this.totalCharge = totalCharge;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Override
    @JsonIgnore
    public Long getId() {
        return uid;
    }

    public int getPhyPower() {
        return phyPower;
    }

    public void setPhyPower(int phyPower) {
        this.phyPower = phyPower;
    }

    public int getDefense() {
        return defense;
    }

    public void setDefense(int defense) {
        this.defense = defense;
    }

    public int getMagPower() {
        return magPower;
    }

    public void setMagPower(int magPower) {
        this.magPower = magPower;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public long getTaoPoint() {
        return taoPoint;
    }

    public void setTaoPoint(long taoPoint) {
        this.taoPoint = taoPoint;
    }

    public long getMonthTaoPoint() {
        return monthTaoPoint;
    }

    public void setMonthTaoPoint(long monthTaoPoint) {
        this.monthTaoPoint = monthTaoPoint;
    }

    public long getPrevMonthTaoPoint() {
        return prevMonthTaoPoint;
    }

    public void setPrevMonthTaoPoint(long prevMonthTaoPoint) {
        this.prevMonthTaoPoint = prevMonthTaoPoint;
    }

    public long getPartyId() {
        return partyId;
    }

    public void setPartyId(long partyId) {
        this.partyId = partyId;
    }

    public short getRoleIcon() {
        return roleIcon;
    }

    public void setRoleIcon(short roleIcon) {
        this.roleIcon = roleIcon;
    }

    public int getFight_cap() {
        return fight_cap;
    }

    public void setFight_cap(int fight_cap) {
        this.fight_cap = fight_cap;
    }
    // add:e
}

